package com.neusoft.neuiotms.dcom.model.insurance;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_insurance_register")
@org.hibernate.annotations.Table(appliesTo = "neuiot_insurance_register", comment = "重保服务登记表")
public class InsuranceRegister extends AbstractAuditModel {

    private static final long serialVersionUID = 3279801563059522797L;

    /** 服务编码 */
    @NotBlank(message = "服务编码")
    @Length(max = 255, message = "服务编码不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '服务编码'")
    private String code;

    /** 服务开始时间 */
    @Column(nullable = true)
    private Date startTime;

    /** 服务结束时间 */
    @Column(nullable = true)
    private Date endTime;

    /** 备注 */
    @Lob
    @Column(columnDefinition = "text")
    @Comment("text COMMENT '备注'")
    private String remarks;

    /** 客户联系人 */
    @Length(max = 255, message = "客户联系人不能超过{max}位")
    @Column(length = 255)
    @Comment("varchar(255) COMMENT '客户联系人'")
    private String customerContact;

    /** 客户联系人电话 */
    @Length(max = 255, message = "客户联系人电话不能超过{max}位")
    @Column(length = 255)
    @Comment("varchar(255) COMMENT '客户联系人电话'")
    private String customerContactPhone;

    /** 是否发布任务 */
    @Comment("bit(1) NOT NULL COMMENT '是否发布任务'")
    private Boolean releaseStatus = false;

    /** 关联服务登记单位表 */
    @OneToMany(mappedBy = "insuranceRegister", cascade = {CascadeType.ALL })
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<InsuranceRegisterUnit> registerUnit = new ArrayList<>();

    /** 关联服务登记任务表 */
    @OneToMany(mappedBy = "insuranceRegister", cascade = {CascadeType.ALL })
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<InsuranceRegisterTask> registerTask = new ArrayList<>();

}
